﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLT_Public;
using System.Data;

namespace QLT_Data
{
   public  class CTHoaDonNhap_Data
    {
       KetNoiCSDL_Data kn = new KetNoiCSDL_Data();
       public DataTable LayDuLieu()
       {
           return kn.LayDuLieu("Load_tbl_CTHoaDonNhap");
       }
       public DataTable TaoBang(string sql)
       {
           return kn.taoBang(sql);
       }
       public int Insert_CTHoaDonNhap(CTHoaDonNhap_Public maHDN, CTHoaDonNhap_Public maThuoc, CTHoaDonNhap_Public ngaySX, CTHoaDonNhap_Public soLuong, CTHoaDonNhap_Public dVT, CTHoaDonNhap_Public giaNhap, CTHoaDonNhap_Public nguoiGiao, CTHoaDonNhap_Public maNV)
       {
           int Nparameter = 8;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaHDN";
           value[0] = maHDN.MaHDN;
           name[1] = "@MaThuoc";
           value[1] = maThuoc.MaThuoc;
           name[2] = "@NgaySX";
           value[2] = ngaySX.NgaySX;
           name[3] = "@SoLuong";
           value[3] = soLuong.SoLuong;
           name[4] = "@DVT";
           value[4] = dVT.DVT;         
           name[5] = "@GiaNhap";
           value[5] = giaNhap.GiaNhap;
           name[6] = "@NguoiGiao";
           value[6] = nguoiGiao.NguoiGiao;
           name[7] = "@MaNV";
           value[7] = maNV.MaNV;
           return kn.update("insert_CTHoaDonNhap", name, value, Nparameter);
       }
       public int Update_CTHoaDonNhap(CTHoaDonNhap_Public maHDN, CTHoaDonNhap_Public maThuoc, CTHoaDonNhap_Public ngaySX, CTHoaDonNhap_Public soLuong, CTHoaDonNhap_Public dVT, CTHoaDonNhap_Public giaNhap, CTHoaDonNhap_Public nguoiGiao, CTHoaDonNhap_Public maNV)
       {
           int Nparameter = 8;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaHDN";
           value[0] = maHDN.MaHDN;
           name[1] = "@MaThuoc";
           value[1] = maThuoc.MaThuoc;
           name[2] = "@NgaySX";
           value[2] = ngaySX.NgaySX;
           name[3] = "@SoLuong";
           value[3] = soLuong.SoLuong;
           name[4] = "@DVT";
           value[4] = dVT.DVT;
           name[5] = "@GiaNhap";
           value[5] = giaNhap.GiaNhap;
           name[6] = "@NguoiGiao";
           value[6] = nguoiGiao.NguoiGiao;
           name[7] = "@MaNV";
           value[7] = maNV.MaNV; return kn.update("update_CTHoaDonNhap", name, value, Nparameter);
       }
       public int Delete_CTHoaDonNhap(CTHoaDonNhap_Public maHDN, CTHoaDonNhap_Public maThuoc)
       {
           int Nparameter = 2;
           string[] name = new string[Nparameter];
           object[] value = new object[Nparameter];
           name[0] = "@MaHDN";
           value[0] = maHDN.MaHDN;
           name[1] = "@MaThuoc";
           value[1] = maThuoc.MaThuoc;
           return kn.update("delete_CTHoaDonNhap", name, value, Nparameter);
       }
    }
}
